/**
 * Class:SelectCommentAction Class
 * Description:This ACtionClass used for retrieval of comments of a particular post
 */

package com.actions;

import com.DAO.CommentDAO;
import com.beans.CommentForm;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class SelectCommentAction extends Action {
	private final static String SUCCESS = "Success";

	/**
	 * This is the action called from the Struts framework.
	 * 
	 * @param mapping
	 *            The ActionMapping used to select this instance.
	 * @param form
	 *            The optional ActionForm bean for this request.
	 * @param request
	 *            The HTTP Request we are processing.
	 * @param response
	 *            The HTTP Response we are processing.
	 * @throws java.lang.Exception
	 * @return
	 */
	@SuppressWarnings("finally")
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		CommentDAO cmntdao = new CommentDAO();
		CommentForm commentForm = (CommentForm) form;
		List<CommentForm> list = new ArrayList<CommentForm>();
		int postId = commentForm.getNoticeId();
		//ArrayList alist = null;
		try {
			list = cmntdao.get(postId);
		} catch (Exception e) {
			e.printStackTrace();
		}

		
			cmntdao.closeConnection();
			return mapping.findForward(SUCCESS);
		
	}
}
